package com.mall.mapper;

import com.mall.pojo.Address;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 地址Mapper接口
 */
@Mapper
public interface AddressMapper {
    
    /**
     * 根据用户ID查询地址列表
     */
    @Select("SELECT id, user_id AS userId, receiver, contact, full_location AS fullLocation, " +
            "address, is_default AS isDefault FROM user_address WHERE user_id = #{userId} ORDER BY is_default ASC")
    List<Address> selectByUserId(Long userId);
    
    /**
     * 根据ID查询地址
     */
    @Select("SELECT id, user_id AS userId, receiver, contact, full_location AS fullLocation, " +
            "address, is_default AS isDefault FROM user_address WHERE id = #{id}")
    Address selectById(Long id);
} 